<%@page import="com.mode.YiFu"%>
<%@page import="org.apache.jasper.tagplugins.jstl.core.ForEach"%>
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import="java.util.*"%>
<%@page import="com.mode.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Shopping Cart</title>
        
    </head>
    <body>
   		<% 
   			if(session.getAttribute("list")==null){
   				out.print("您还没有添加商品。。。");
   			}else{
	   		    List<Object> list = (List<Object>)session.getAttribute("list");
	   		    out.print(list.size()); 
	   		    if(list.size()==0){
	   		    	out.print("购物车空了。。。");
	   		    }else{
		   		    out.print("<ul>");
		   		    int id=0;
			   		for(Object obj:list){
			   		    out.print("<li>");
			   		    String className=obj.getClass().getSimpleName();
			   		    if(className.equals("YiFu")){
			   		    YiFu yiFu=(YiFu)obj;
			   		    out.print("id="+id+"\t"+yiFu.getName()+"\t"+yiFu.getPrice()+"\t"+yiFu.getNum());
			   		    }
			   		    if(className.equals("Shoes")){
			   		       Shoes shoes=(Shoes)obj;
			   			   out.print("id="+id+"\t"+shoes.getName()+"\t"+shoes.getPrice()+"\t"+shoes.getNum());
			   			   }
			   			if(className.equals("Glasses")){
			   			    Glasses glasses=(Glasses)obj;
			   				out.print("id="+id+"\t"+glasses.getName()+"\t"+glasses.getPrice()+"\t"+glasses.getNum());
			   			}
			   			out.print("<a href='http://127.0.0.1:8080/weba/deleteServlet?id="+id+"'>删除</a>"+"</li>");
			   			id++;
			   		}
		   		   out.print("</ul>");
	   		   }
   			}
   		%>
		
		<a href="firstPage.jsp">返回主页</a>
 	</body>
</html>